# from selenium import webdriver
# import time
#
# driver = webdriver.Chrome()
# time.sleep(5)
# driver.quit()

# # 自动解决环境依赖
# from selenium import webdriver
# from webdriver_manager.chrome import ChromeDriverManager
# from webdriver_manager.utils import ChromeType
#
# driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())
# # time.sleep(5)
# driver.quit()

from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
# #获取浏览器尺寸
# print(driver.get_window_size())
# time.sleep(2)
driver.maximize_window()
# print(driver.get_window_size())
# time.sleep(2)
# # 设置浏览器尺寸
# driver.set_window_size(800, 800)
# # 获取浏览器位置
# print(driver.get_window_position())
# # 设置浏览器位置
# driver.set_window_position(200, 200)
# time.sleep(5)
# # print(dir(driver))

# 请求指定页面
driver.get("https://www.baidu.com")
time.sleep(2)
# print(driver.current_url)
# print(driver.title)
# driver.get_screenshot_as_file('.\my_demo.png')
# print(driver.page_source)
# # 刷新当前页面
# driver.refresh()
# driver.find_element_by_xpath("//input[@id='kw']").send_keys("python")
# driver.find_element(By.XPATH, "//input[@id='kw']").send_keys("python")
driver.find_element('xpath', "//input[@id='kw']").send_keys("python")
# print(By.XPATH)
# driver.find_element_by_xpath("//input[@type='submit']").click()
# driver.find_element(By.XPATH, "//input[@type='submit']").click()
driver.find_element('xpath', "//input[@type='submit']").click()
time.sleep(2)
# # 回退页面
# driver.back()
# time.sleep(2)
# driver.forward()
time.sleep(5)
driver.quit()


